package com.example.steveaoblogdemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.steveaoblogdemo.entity.Articles;
import com.example.steveaoblogdemo.entity.Tag;
import com.example.steveaoblogdemo.utils.Result;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TagMapper extends BaseMapper<Tag> {
    @Insert("insert into tag(id,t_name) values (#{id},#{tName})")
    int addTag(Integer id,String tName);

    @Update("update tag set t_name = #{tName} where id=#{id}")
    int updateTag(String tName,Integer id);

    @Select("select a.* from articles a,tag t where a.tags=t.t_name and a.status=0 and  t.id=#{id}")
    List<Articles> query(Integer id);

}
